package org.jeecg.modules.controller;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.jeecg.modules.service.BackformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author ldd
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("hitokoto")
public class HitokotoController {
    @Autowired
    BackformService service;
    @RequestMapping(value = "/get" , method = RequestMethod.GET)
    public HashMap<String,Object> api(){
        String target = "https://v1.hitokoto.cn/";
        String s = HttpUtil.get(target);
        JSONObject entries = JSONUtil.parseObj(s);
        HashMap<String, Object> map = new HashMap<>();
        map.put("text",entries.get("hitokoto"));
        map.put("by",entries.get("from_who")+"——"+entries.get("from"));
        return map;
    }
}
